Repository navigation
fusion: pointer index nodes, small-int reads, globals by name hash - #4804
Merged
Merged
Conversation
The binary operation families and the two-argument call family each stamp a node for a global on the left and a local on the right, but no match line ever picked it, so the node was never created. The match now names GetGlobalR2V with GetLocalR2V: under solid_context `global op local` and `f(global, local)` are one node each. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
p[i] on a pointer had no fused node: every read and store paid for the index node, the pointer read and the index read. It now has a fused read, a read by reference and a store, from a local, argument, global or expression pointer, with an int or uint index. The array and fixed-array index families take int8, uint8, int16 and uint16 elements, and a global found by name hash as a base, so a context that is not solid fuses its global tables too. A small int read from memory travels widened to 32 bits, so a cast of one to int or uint changes nothing. A fused small-int read answers evalInt and evalUInt itself: the cast over a local, a local reference or an argument reference becomes one widened read, and the cast over a fused index read is removed. A narrowing cast from int or uint under a small-int pointer store is removed the same way. SimSourceType gains sGlobalMnh, and PtrAtR2V reports its index width in its node name, which changes the semantic hash of a function that indexes a pointer with a uint or 64-bit index. src/simulate/ARCHITECTURE.md states the contract. benchmarks/README.md also gains rows for two older fusion benchmarks it did not list. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AOT output must be regenerated: functions that index a pointer, read a small-int element or index a global array get a new semantic hash - anyone shipping pre-generated AOT regenerates it.
Why. C-style code paid one interpreter node per step for
p[i],*p = vandtable[int(bytes[i])]: the Doom column loop was 10 node calls per pixel.What changes.
p[i]on a pointer has fused read, by-reference and store nodes.int8/uint8/int16/uint16elements, and a global found by name hash.int/uintfolds into the read below it.Global,Localstamp of binary operations and two-argument calls gets its match line.Observable behavior.
p[i] = uint8(v): 6.3 -> 2.6 ns;int(bytes[i]): 6.5 -> 3.4 ns.log_nodesshows new node names;PtrAtR2Vwith auintor 64-bit index printsPtrAtR2V_U32/_I64/_U64.Where to look.
simulate_fusion_ptr_at.cppagainstSimNode_PtrAt,SimNode_SetandSimNode_Ptr2Ref, andFusionPoint_WidenwithisFusedOp2, which removes a cast only over a fused read.Validation, claims, ledger
Validation
ci/release_modules.txtmodule set), headbf1d8e8a23.compile-sweeponutils/find-dupemissing its daspkg dependency on that box (installed). The two gates and every lane the red tier skipped were then run once with--only:lint,compile-sweep,tests-cpp,tests-interp,tests-jit,watchdog-interp,watchdog-jit,tests-aot,utils-testsall pass. Thetests-aotlane is thetest_aotrun on the head commit thattests/REVIEW.mdasks for.docs/digestreports the shipped digest stale. The baseline binary regenerates the same difference on its own tree on that box (descriptions of global constants missing), so the red does not come from this change; CI keeps that gate off.docs/sphinx-htmlskipped: nosphinx-buildon the box. The diff touches nothing the doc workflow watches.DAS_FUSIONlevels CI does not pair with these tests: MinSizeRel (level 1) and Debug (level 0) builds each pass the seven touched test files; the level-1 node dump shows the small-int,GlobMnhand widened-read nodes in use.int/uint; a cast is removed only over a fused read; fixed-array and array bounds checks with an expression index; the null check of*p = v(crashes without it); element width and sign of the widened read and of the pointer small-int load; the pointer address uses the index; the store writes the evaluated value; theGlobal,Localstamp reads the global (crashes when mis-stamped). 11 of 11 fail as required.options log_nodes) confirm the tests reach what they name:FastCall2GlobLocforf(global, local);ArrayAtR2VULocLoc<uint8>andAtR2VULocLoc<int8>under bound-check elision with no cast above; a small-int read with a 64-bit pointer index, and one through a pointer field, keep their cast.src/simulate/ARCHITECTURE.md:DAS_FUSION_WIDE_NODE(simulate_fusion.h) andg_fusedSmallIntReads(simulate_fusion_widen.cpp) match#fused-small-int-reads;SimNode_PtrAtFusion(simulate_fusion_ptr_at.cpp) matches#pointer-index-family; the hook macros insimulate_fusion_op2_set_impl.hmatch#global-by-hash-source.benchmarks/fusion/):p[i]int 4.4 -> 2.6;int(p[i])uint8 6.9 -> 2.8;p[i] = vint 4.6 -> 2.2;*p = v3.6 -> 2.6;lut[int(bytes[i])]8.7 -> 5.9; global array read, local index, not solid 4.8 -> 3.5; global fixed-array read, not solid 5.4 -> 4.8;int(c)on a loop variable 3.8 -> 2.2; Doom column loop 17.8 -> 15.0;g * localundersolid_context3.0 -> 2.0. Run-to-run noise is about 0.5 ns.simulate_fusion_ptr_at.cppcompiles in 5.2 s with clang-19 and its object is 3.7 MB;libDaScriptDyn.sogrows from 50.1 MB to 54.0 MB.Claims - stated, not tested
SimNode_PtrAt::computeandSimNode_Set::eval. A test would have to pin an evaluation order the language does not define across tiers. A break would show as a different element read or written when the index or the value expression changes the pointer.GlobMnhbase reads the global through the hash lookup, not the stored offset. Verified by reading (computeGlobalMnh). In one context both give the same address, so no test tells them apart.uintindex of 2^31 or more, and astride * indexproduct that wraps 32 bits, behave as on the non-fused node. Verified by reading: the address expression is the same expression with the same index type. A test would need a 2 GB buffer.PtrAtR2VNamegives each index width its own node name, and only theintanduintnames are registered.intelements and every element type with a local pointer; one class template serves all of them.Not done
Set, the binary operations, calls and table index: only the array, fixed-array and pointer index families take it.Global,Localpair.p[i] = localstill goes through the reference copy node.DAS_FUSION1.GetLocalR2VToInt,GetLocalRefOffR2VToIntandGetArgumentRefOffR2VToIntalthough one node serves both theintand theuintcast;FusionPoint_Widenkeeps its own visit for those names.REVIEW.md,src/REVIEW.md,tests/REVIEW.mdandinclude/daScript/simulate/REVIEW.mdthemselves are not edited here.